package org.dtrd.config.wechat.entity.bean.officialaccount.template;

import lombok.Data;
import lombok.extern.slf4j.Slf4j;
import org.dtrd.config.common.PathUtil;
import org.dtrd.config.wechat.config.WechatUtil;
import org.dtrd.config.wechat.entity.bean.officialaccount.WechatOaTemplateMsg;
import org.dtrd.config.wechat.entity.bean.officialaccount.WechatTemplateMiniProgram;

@Data
@Slf4j
public class SigninMissMsg extends WechatOaTemplateMsg {
    /**
     *  姓名
     */
    private String patientName;

    /**
     *  打卡项目
     */
    private String signinName;

    /**
     *  打卡时间
     */
    private String signinTime;

    /**
     *  状态
     */
    private String signinstate;

    public static final class SigninMissMsgBuilder {
        private SigninMissMsg SigninMissMsg;

        private SigninMissMsgBuilder() {
            SigninMissMsg = new SigninMissMsg();
        }

        public static SigninMissMsgBuilder singleInstance() {
            return new SigninMissMsgBuilder();
        }

        public SigninMissMsgBuilder withMsgTitle(String msgTitle) {
            SigninMissMsg.setMsgTitle(msgTitle);
            return this;
        }

        public SigninMissMsgBuilder withUrl(String url) {
            SigninMissMsg.setUrl(url);
            return this;
        }

        public SigninMissMsgBuilder withMiniProgram(WechatTemplateMiniProgram miniProgram) {
            SigninMissMsg.setMiniProgram(miniProgram);
            return this;
        }

        public SigninMissMsgBuilder withRemark(String remark) {
            SigninMissMsg.setRemark(remark);
            return this;
        }

        public SigninMissMsgBuilder withMsgTime(String msgTime) {
            SigninMissMsg.setMsgTime(msgTime);
            return this;
        }

        public SigninMissMsgBuilder withsigninName(String signinName) {
            SigninMissMsg.setSigninName(signinName);
            return this;
        }

        public SigninMissMsgBuilder withPatientName(String patientName) {
            SigninMissMsg.setPatientName(patientName);
            return this;
        }

        public SigninMissMsgBuilder withSigninTime(String signinTime) {
            SigninMissMsg.setSigninTime(signinTime);
            return this;
        }

        public SigninMissMsgBuilder withsigninState(String signinState) {
            SigninMissMsg.setSigninstate(signinState);
            return this;
        }

        public SigninMissMsg build() {
            return SigninMissMsg;
        }

        /**
         * 配置给医生的患者打卡成功消息
         *
         * @param patientId   患者Id
         */

        public SigninMissMsg buildSigninSuccessMsg(String patientName, String signinTime, Integer patientId) {
            this.withMsgTitle("患者已完成饮食打卡，请及时反馈建议及评分").withPatientName(patientName)
                    .withSigninTime(signinTime).withsigninState("打卡成功")
                .withRemark("点击查看打卡详情")
                .withUrl(PathUtil.getH5Domain() + "/patient/BloodProfile/diet.html?pid=" + patientId);
            return this.build();
        }

        /**
         * 配置漏打卡信息
         *
         * @param msgTitle
         * @param patientName
         * @param signinName
         * @param remark
         * @param url
         * @return
         */
        public SigninMissMsgBuilder buildSigninMissMsg(String msgTitle, String patientName, String signinName, String remark, String url, String from) {
            this.withMsgTitle(msgTitle).withPatientName(patientName)
                    .withsigninName(signinName).withsigninState("未打卡")
                    .withRemark(remark)
                    .withUrl(url);
            log.info("SigninMissMsgBuilder.buildSigninMissMsg.[msgTitle={}, patientName={}, cloclinName={}, remark={}, url={}, from={}", msgTitle, patientName, signinName, remark, url, from);
            return this;
        }
    }
}
